<template>
  <div class="content">
    <div class="fathers">
      <div class="active">
        <div class="header">实有人口</div>
        <div class="bodyobj">
          <div class="body" >
            <div class="description">
              <span>人口总数</span>
              <br />
              <i>28</i>
            </div>
            <img src="../../assets/切图-人口分析_slices/人口总数.png" alt />
          </div>
          <div class="body" id="img2">
            <div class="description">
              <span>常住人口</span>
              <br />
              <i>28</i>
            </div>
            <img src="../../assets/切图-人口分析_slices/常住人口.png" alt />
          </div>
          <div class="body" id="img3">
            <div class="description">
              <span>暂住人口</span>
              <br />
              <i>28</i>
            </div>
            <img src="../../assets/切图-人口分析_slices/暂住人口.png" alt />
          </div>
          <div class="body" id="img4">
            <div class="description">
              <span>外籍住人口</span>
              <br />
              <i>28</i>
            </div>
            <img src="../../assets/切图-人口分析_slices/外籍人口.png" alt />
          </div>
        </div>
      </div>
      <div class="scale">
        <div class="header">男女比例</div>
        <div class="model">
          <div class="left">
            <div class="man">
              <img src="../../assets/切图-人口分析_slices/男性.png" alt />
              <div>男性人数</div>
              <i>3208</i>
            </div>
            <div class="woman">
              <img src="../../assets/切图-人口分析_slices/女性.png" alt />
              <div>女性人数</div>
              <i>3208</i>
            </div>
          </div>
          <div class="right">
            <div id="ratio"></div>
            <div class="ratiotext">
              <div>男女比例</div>
              <span class="number">1.3 : 1</span>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div style="display:flex;flex:wrap;">
      <div class="father" v-if="flow">
        <div id="flow"></div>
        <div class="son">
          <div>近30天人口流动分布图</div>
          <div class="img" @click="flowhidden">
            <img src="../../assets/切图-人口分析_slices/取消.png" alt />
          </div>
        </div>
      </div>
      <div class="father" v-if="register">
        <div id="register"></div>
        <div class="son">
          <div>户籍分布图</div>
          <div class="img" @click="registerhidden">
            <img src="../../assets/切图-人口分析_slices/取消.png" alt />
          </div>
        </div>
      </div>
      <div class="father" v-if="age">
        <div id="age"></div>
        <div class="son">
          <div>人口年龄结构分布图</div>
          <div class="img" @click="agehidden">
            <img src="../../assets/切图-人口分析_slices/取消.png" alt />
          </div>
        </div>
      </div>
    </div>
    <div style="display:flex;flex:wrap;">
      <div class="father" v-if="love">
        <div id="love"></div>
        <div class="son">
          <div>关注人群</div>
          <div class="img" @click="lovehidden">
            <img src="../../assets/切图-人口分析_slices/取消.png" alt />
          </div>
        </div>
      </div>
      <div class="father" v-if="study">
        <div id="study"></div>
        <div class="son">
          <div>文化程度分析图</div>
          <div class="img" @click="studyhidden">
            <img src="../../assets/切图-人口分析_slices/取消.png" alt />
          </div>
        </div>
      </div>
      <div class="father" v-if="grid">
        <div id="grid"></div>
        <div class="son">
          <div>网格人口统计</div>
          <div class="img" @click="gridhidden">
            <img src="../../assets/切图-人口分析_slices/取消.png" alt />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import echarts from "echarts";
export default {
  name: "Dashboard",
  components: {},
  data() {
    return {
      flow: true,
      register: true,
      age: true,
      love: true,
      study: true,
      grid: true
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {
    var myChart1 = echarts.init(document.getElementById("flow"));
    var option1 = {
      backgroundColor: "#fff",
      //  图表距边框的距离,可选值：'百分比'¦ {number}（单位px）
      grid: {
        top: "16%", // 等价于 y: '16%'
        left: "3%",
        right: "8%",
        bottom: "3%",
        containLabel: true
      },

      // 提示框
      tooltip: {
        trigger: "axis"
      },

      //工具框，可以选择
      // toolbox: {
      //     feature: {
      //         saveAsImage: {} //下载工具
      //     }
      // },

      xAxis: {
        type: "category",
        axisLine: {
          lineStyle: {
            // 设置x轴颜色
            color: "#000"
          }
        },
        // boundaryGap值为false的时候，折线第一个点在y轴上
        boundaryGap: false,
        data: ["3月5号", "3月10号", "3月15号", "3月20号", "3月25号", "3月30号"]
      },

      yAxis: {
        type: "value",
        min: 0, // 设置y轴刻度的最小值
        max: 1800, // 设置y轴刻度的最大值
        splitNumber: 9, // 设置y轴刻度间隔个数
        axisLine: {
          lineStyle: {
            // 设置y轴颜色
            color: "#000"
          }
        }
      },

      series: [
        {
          name: "可用车位数量统计",
          data: [820, 932, 301, 1434, 1290, 1330],
          type: "line",
          // 设置小圆点消失
          // 注意：设置symbol: 'none'以后，拐点不存在了，设置拐点上显示数值无效
          symbol: "none",
          // 设置折线弧度，取值：0-1之间
          smooth: 0.5,
          areaStyle: {}
        }
      ],

      color: ["#B7DDD0"]
    };
    myChart1.setOption(option1);
    var myChart2 = echarts.init(document.getElementById("register"));
    var option2 = {
      color: "#3E8FFD",
      xAxis: {
        type: "category",
        data: ["江苏", "安徽", "江西", "湖南", "湖北", "河南", "四川", "未知"]
      },
      yAxis: {
        type: "value"
      },
      series: [
        {
          data: [120, 200, 150, 80, 70, 110, 130, 222],
          type: "bar"
        }
      ]
    };
    myChart2.setOption(option2);
    var myChart3 = echarts.init(document.getElementById("age"));
    var option3 = {
      color: ["#FEA0C9", "#6F9EFD"],
      tooltip: {
        trigger: "axis",
        axisPointer: {
          type: "shadow"
        }
      },
      legend: {
        top: 30,
        right: 0,
        data: ["女", "男"]
      },
      grid: {
        left: "3%",
        right: "4%",
        bottom: "3%",
        containLabel: true
      },
      xAxis: {
        type: "value",
        boundaryGap: [0, 0.01],
        show: false
      },
      yAxis: {
        type: "category",
        data: [
          "0-10",
          "10-19",
          "20-29",
          "30-39",
          "40-49",
          "50-59",
          "60-69",
          "70-79",
          "80-89",
          "90-99",
          "100以上"
        ]
      },
      series: [
        {
          name: "女",
          type: "bar",
          data: [
            18203,
            23489,
            29034,
            104970,
            131744,
            630230,
            18203,
            23489,
            29034,
            104970,
            131744
          ]
        },
        {
          name: "男",
          type: "bar",
          data: [
            193251,
            23438,
            31000,
            121594,
            134141,
            681807,
            19325,
            23438,
            31000,
            121594,
            134141
          ]
        }
      ]
    };
    myChart3.setOption(option3);
    var myChart4 = echarts.init(document.getElementById("love"));
    var option4 = {
      color: ["#114791", "#4587D8", "#4FAFFC", "#40C363"],
      tooltip: {
        trigger: "item",
        formatter: "{a} <br/>{b} : {c} ({d}%)"
      },
      legend: {
        orient: "vertical",
        top: 200,
        right: 50,
        icon: "circle",
        data: ["低保人员", "残疾人", "高龄老人", "空巢老人"]
      },
      series: [
        {
          name: "访问来源",
          type: "pie",
          radius: "55%",
          center: ["45%", "52%"],
          label: {
            position: "inner",
            color: "#ccc"
          },
          labelLine: {
            show: false
          },
          data: [
            { value: 310, name: "低保人员" },
            { value: 234, name: "残疾人" },
            { value: 135, name: "高龄老人" },
            { value: 154, name: "空巢老人" }
          ],
          emphasis: {
            itemStyle: {
              shadowBlur: 10,
              shadowOffsetX: 0,
              shadowColor: "rgba(0, 0, 0, 0.5)"
            }
          }
        }
      ]
    };
    myChart4.setOption(option4);
    var myChart5 = echarts.init(document.getElementById("study"));
    var option5 = {
      color: [
        "#73A0FB",
        "#73DEB4",
        "#75839F",
        "#F4C537",
        "#EC7C6A",
        "#98D8F3",
        "#A286D3",
        "#FFAC68"
      ],
      tooltip: {
        trigger: "item",
        formatter: "{a} <br/>{b}: {c} ({d}%)"
      },
      legend: {
        orient: "vertical",
        right: 10,
        top: "middle",
        data: ["小学", "初中", "高中", "专科", "本科", "研究生", "博士", "其他"]
      },
      series: [
        {
          name: "访问来源",
          type: "pie",
          radius: ["50%", "70%"],
          avoidLabelOverlap: false,
          label: {
            show: false,
            position: "center"
          },
          emphasis: {
            label: {
              show: true,
              fontSize: "30",
              fontWeight: "bold"
            }
          },

          labelLine: {
            length: 20,
            length2: 50
          },
          label: {
            formatter: "{b}\n\n",
            padding: [0, -55]
          },

          data: [
            { value: 335, name: "小学" },
            { value: 310, name: "初中" },
            { value: 234, name: "高中" },
            { value: 135, name: "专科" },
            { value: 154, name: "本科" },
            { value: 234, name: "研究生" },
            { value: 135, name: "博士" },
            { value: 154, name: "其他" }
          ]
        }
      ]
    };
    myChart5.setOption(option5);
    var myChart6 = echarts.init(document.getElementById("grid"));
    var option6 = {
      color: ["#6F6DF8", "#76D9C8", "#686998", "#E5F030", "#E0955F", "#82ABEC"],
      tooltip: {
        trigger: "item",
        formatter: "{a} <br/>{b} : {c} ({d}%)"
      },
      legend: {
        orient: "vertical",
        top: "middle",
        left: "right",
        data: ["直接访问", "邮件营销", "联盟广告", "视频广告", "搜索引擎"]
      },
      series: [
        {
          name: "访问来源",
          type: "pie",
          radius: "55%",
          center: ["50%", "60%"],
          data: [
            { value: 335, name: "直接访问" },
            { value: 310, name: "邮件营销" },
            { value: 234, name: "联盟广告" },
            { value: 135, name: "视频广告" },
            { value: 348, name: "搜索引擎" }
          ],
          roseType: "angle",
          // 文字调整
          emphasis: {
            itemStyle: {
              shadowBlur: 10,
              shadowOffsetX: 0,
              shadowColor: "rgba(0, 0, 0, 0.5)"
            }
          },
          labelLine: {
            show: false
          },
          label: {
            position: "outside",

            align: "center"
          }
        }
      ]
    };
    myChart6.setOption(option6);
    var myChart = echarts.init(document.getElementById("ratio"));
    var option = {
      color: ["#749EFB", "#FDA6C9"],
      tooltip: {
        trigger: "item",
        formatter: "{a} <br/>{b}: {c} ({d}%)"
      },
      series: [
        {
          name: "访问来源",
          type: "pie",
          radius: ["50%", "70%"],
          avoidLabelOverlap: false,
          label: {
            show: false,
            position: "center"
          },
          emphasis: {
            label: {
              show: true,
              fontSize: "30",
              fontWeight: "bold"
            }
          },
          labelLine: {
            show: false
          },
          data: [
            { value: 380, name: "男" },
            { value: 300, name: "女" }
          ]
        }
      ]
    };
    myChart.setOption(option);
  },
  methods: {
    flowhidden() {
      this.flow = false;
    },
    registerhidden() {
      this.register = false;
    },
    agehidden() {
      this.age = false;
    },
    lovehidden() {
      this.love = false;
    },
    studyhidden() {
      this.study = false;
    },
    gridhidden() {
      this.grid = false;
    }
  }
};
</script>
<style lang="scss" scoped>
.fathers {
  display: flex;
  .active {
    width: 1080px;
    height: 248px;
    background: #ffffff;
    border-radius: 10px;
    padding: 18px 29px;
    height: 250px;
    margin-bottom: 25px;
    margin-right: 18px;
    .header {
      font-size: 20px;
      margin-bottom: 35px;
      padding: 9px 0 19px 0;
      border-bottom: 1px solid #f5f5f5;
    }
    .bodyobj {
      display: flex;
      .body {
        position: relative;
        margin-right: 15px;
        width: 248px;
        height: 110px;
        .description {
          position: absolute;
          top: 32px;
          left: 23px;
          span {
            font-size: 16px;
            color: #fff;
          }
          i {
            font-style: initial;
            font-size: 28px;
            color: #fff;
          }
        }
        img {
          width: 100%;
        }
      }
    }
  }
  .scale {
    padding: 16px 20px;
    border-radius: 10px;
    width: 750px;
    height: 248px;
    background-color: #fff;
    .header {
      font-size: 20px;
      padding: 9px 0 19px 0;
      border-bottom: 1px solid #f5f5f5;
    }
    .model {
      position: relative;
      height: 150px;
      width: 480px;
      .left {
        position: absolute;
        top: 25px;
        width: 260px;
        height: 120px;
        border-right: 2px solid #f5f5f5;
        .man {
          width: 120px;
          height: 110px;
          text-align: center;
          float: left;
          margin-right: 18px;
          > div {
            font-size: 16px;
            margin: 10px 0;
          }
          i {
            font-style: initial;
            font-weight: 700;
            font-size: 32px;
          }
        }
        .woman {
          width: 120px;
          height: 110px;
          text-align: center;
          float: left;
          > div {
            font-size: 16px;
            margin: 10px 0;
          }
          i {
            font-style: initial;
            font-weight: 700;
            font-size: 32px;
          }
        }
      }
      .right {
        position: absolute;
        left: 260px;
        top: 20px;
        width: 320px;
        height: 130px;
        .ratiotext {
          position: absolute;
          top: 42px;
          left: 130px;
          width: 90px;
          height: 70px;
          margin-left: 10px;
          .number {
            font-size: 28px;
            color: skyblue;
          }
        }
      }
    }
  }
}
#flow,
#register,
#age,
#love,
#study,
#grid {
  position: absolute;
  top: 45px;
  width: 100%;
  height: 90%;
  border-radius: 10px;
  border-top: 1px solid #f5f5f5;
}

.father {
  background-color: #fff;
  position: relative;
  margin-right: 20px;
  margin-bottom: 22px;
  border-radius: 10px;
  flex: 1;
  height: 481px;
  .son {
    position: absolute;
    top: 15px;
    left: 33px;
    padding-bottom: 16px;
    display: flex;
    justify-content: space-between;
    width: 480px;
    font-size: 16px;
  }
  @media screen and (max-width: 1500px) {
    .son {
      width: 340px;
    }
  }
  @media screen and (min-width: 1500px) and (max-width: 1800px) {
    .son {
      width: 400px;
    }
  }
}


#ratio {
  width: 150px;
  height: 130px;
  margin-left: 10px;
}
</style>

